<?php

namespace App\Http\Controllers\Admin;

use App\Common\Comiter;
use App\Common\JwtToken;
use App\Common\RedisSingleton;
use App\Dmeo\DayLogin;
use App\Http\Controllers\Controller;
use App\Http\Middleware\CheckApiLogin;
use App\Validates\LoginHomePostRequest;
use Illuminate\Http\Request;

class LoginHome extends Controller
{
    //用户登陆 岳椿霖
    public function HomeLoginArticle(LoginHomePostRequest $request)
    {
        try {
            if($request->method()!= 'POST')throw new \Exception('请求方式不正确');
            //哈希加密
//            $password = password_hash($password['password'],PASSWORD_BCRYPT,['cost' => 12]);
            $name = $request->only("name");
            $password = $request->only("password");
            $password = md5($password['password']);

            $redis = RedisSingleton::getInstance();//Redis缓存
            $redis->select(2);
            $redis->set("Article",$password);

            $data = DayLogin::AuthLoginHome(implode($name) , $password);
            JwtToken::getInstance()->createToken($data);//获取token密钥
            return Comiter::success(200,"连接成功",$data);

        }catch (\Exception $e)
        {
             return Comiter::fail(510, '数据方式有问题', $e->getMessage());
        }

    }


    public function HighchartsHose(Request $request)
    {
       return view("EchartsHigh.Highcharts");

    }

    public function statistics(Request $request){

    }




}
